<template>
  <div class="zwdetal">
    <div class="zwlbdetails">
      <ul>
        <li>
          <div style="text-align: left;">
            <!-- <p>
              <span class="datelzygsms">公司信息</span>
            </p>-->
            <div style="display: inline-block;width:6.5rem">
              <p>
                <span class="datelzy datelzywor"
                  style="margin-top: 0.3rem;display: inline-block;">{{reslit.name}}</span>
              </p>
              <p>
                {{reslit.scaleText}}
                <span class="zwfg">|</span>
                {{reslit.natureText}}
              </p>
              <p>{{reslit.tradeText}}</p>
            </div>
            <div style="display: inline-block;float: right;">
              <span>
                <img class="datelzygsmsimg" :src="reslit.logo" />
              </span>
            </div>
          </div>

          <!-- <van-button type="default" class="zwlbfdan">已下线</van-button> -->
          <!-- <van-divider style="color: rgba(121, 121, 121, 1)" /> -->
        </li>
      </ul>
      <van-divider style="color:#323233;border-width: 0.01rem;" />
    </div>

    <div class="zwlbdetails">
      <ul>
        <li>
          <p>
            <span class="datelzygsms" style="font-size: 0.6rem;">公司介绍</span>
          </p>
          <p ref="element" :style="{height:ckheight,overflow: 'hidden'}" v-html="reslit.profile">
            {{reslit.profile}}</p>

          <div class="ckqb" @click="ckqb" v-show="ckshow&&qbshow">查看全部</div>
          <div class="ckqb" @click="ckqb" v-show="!ckshow">收起</div>
        </li>
      </ul>
    </div>

    <div class="nvebarground nvebargroundpsmd"></div>
    <div class="zwlbdetails">
      <ul>
        <li>
          <p class="datelzygsms">在招职位</p>
        </li>
      </ul>
    </div>
    <div class="zwlb zwlbgsxx">
      <!-- <van-cell v-for="item in list" :key="item" :title="item" /> -->
      <div v-if="listnil">暂无数据</div>
      <div class="zwlbdetails">
        <ul>
          <li v-for="(item,index) in list" @click="jobdetails(item.id,item.companyId,item.category)"
            :key="index+'details'">
            <p class="zwlbbt">
              {{item.name}}
              <span class="zwlbsj zwlbsjxz">{{item.wageText}}</span>
            </p>
            <p>
              {{item.educationText?item.educationText:item.educationText===''?"不限":!item.educationText?"不限":item.educationText}}
              <span class="zwfg">|</span>
              {{item.workExpText?item.workExpText:item.workExpText===''?"不限":!item.workExpText?"不限":item.workExpText}}
            </p>
            <p>
              <span>{{reslit.name}}</span>
              <span class="zwlbsj">{{item.refreshTime}}</span>
            </p>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>
<script>
import POSITIONLIST from '@/api/PositionList'
import timedate from '@/assets/js/datatime'
export default {
  data () {
    return {
      zw: '',
      loading: false,
      ckshow: true,
      qbshow: false,
      listnil: false,
      ckheight: '',
      reslit: {
        companyId: '61',

        address: '', // 公司地址

        areaText: '',

        id: '61',

        industryText: '',

        logo: null, // 公司logo

        name: '', // 公司名称
        nature: 50,
        natureText: '',
        onLineJobCount: 5504,

        scale: 81,
        scaleText: '', // 公司规模
        shortName: '',

        tradeText: '',

        describe: '' // 职位藐视
      },
      list: [],
      finished: false
    }
  },
  computed: {},
  methods: {
    onClickRight () { },
    ckqb () {
      this.ckshow = !this.ckshow
      if (this.ckshow) {
        this.ckheight = '3rem'
      } else {
        this.ckheight = ''
      }
      this.$forceUpdate()
    },
    // 获取详情
    // jobget (id) {
    //   // let that = this
    //   POSITIONLIST.jobget(id).then(res => {
    //     console.log(res.data)
    //     if (res.data.code === 200) {
    //       // that.reslit = res.data.data
    //       // if (!that.reslit.companyInfo.logo) {
    //       //   that.reslit.companyInfo.logo = require('../../assets/img/companyimg.png')
    //       // }
    //       // // if (that.reslit.companyInfo.profile.length > 140) {
    //       // //   that.qbshow = true
    //       // // }
    //       // that.reslit.companyInfo.profile = decodeURI(that.reslit.companyInfo.profile)
    //       // that.$nextTick(() => {
    //       //   let height = window.getComputedStyle(this.$refs.element).height
    //       //   console.log(height, 'contentHeight')
    //       //   if (parseInt(height) > 96) {
    //       //     that.qbshow = true
    //       //   }
    //       //   that.ckheight = '3rem'
    //       // })
    //       // console.log(that.reslit.companyInfo.profile.length, 'sssadsad')
    //     }
    //   })
    // },
    // 详情跳转
    jobdetails (id, companyId, category) {
      this.$router.push({
        name: 'Jobdetails',
        query: {
          id: id,
          companyId: companyId,
          category: category
        }
      })
    },
    // 获取公司招聘职位信息
    companyCount () {
      let that = this
      POSITIONLIST.companyCount(this.reslit.companyId).then(res => {
        console.log(res.data)
        if (res.data.code === 200) {
          if (
            res.data.data.jobOutVoList &&
            res.data.data.jobOutVoList.length !== 0
          ) {
            that.list = res.data.data.jobOutVoList
            // 把时间转换成年前，月前，日前
            for (let i = 0; i < res.data.data.jobOutVoList.length; i++) {
              res.data.data.jobOutVoList[i].refreshTime = timedate(
                res.data.data.jobOutVoList[i].refreshTime
              )
            }
          } else {
            that.listnil = true
          }
          that.reslit = res.data.data
          if (!that.reslit.logo) {
            that.reslit.logo = require('../../assets/img/companyimg.png')
          }
          // if (that.reslit.companyInfo.profile.length > 140) {
          //   that.qbshow = true
          // }
          that.reslit.profile = decodeURI(that.reslit.profile)
          that.$nextTick(() => {
            let height = window.getComputedStyle(this.$refs.element).height
            console.log(height, 'contentHeight')
            if (parseInt(height) > 96) {
              that.qbshow = true
            }
            that.ckheight = '3rem'
          })
          console.log(that.reslit, 'sssadsad')
        } else {
          that.listnil = true
        }
      })
    }
  },
  created () {
    if (this.$route.query.companyId) {
      // this.jobget(this.$route.query.id)
      this.reslit.companyId = this.$route.query.companyId
      this.companyCount()
    }
  }
}
</script>
<style scoped></style>
